package Package;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
/**
 * Class Controller.
 * @author Ingrid Campos
 * @author Sandra Calderon
 * */
public class Validate {
	File file = null;
	FileReader fr = null;
	BufferedReader br = null;
	String[] username=new String[2];
    String user;
    String pass;
    String line;
	
    /**
     * verifies that the user exists
     * @param username
     * @param password
     * */
	public boolean readFile(String username1, String password){
	try {
        file = new File ("C:/archivo.txt");
        fr = new FileReader (file);
        br = new BufferedReader(fr);
        
		while((line=br.readLine())!=null){
			username=line.split(" ");
			user=username[0];
			pass=username[1];
			if (username1.equalsIgnoreCase(user)&& password.equals(pass)) {
				return true;
			}
//		    System.out.println(user + " "+pass);
		}
      }
		
    catch(Exception e){
		  e.printStackTrace();
     }finally{
         try{                    
           if( null != fr ){   
               fr.close();     
      }                  
		         }catch (Exception e2){ 
		            e2.printStackTrace();
		         }
		      }
	return false;
	}
}